package com.maxus.mini.ecard.entity.request;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.maxus.mini.common.VersionedAuditableIdEntity;

/**
 * 
 * @author wujinsong
 *
 */
@Entity()
@Table(name = "ecard_request_log")
public class RequestLog extends VersionedAuditableIdEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Override
	public Long getId() {
		return id;
	}
	
	/**
	 * 请求id
	 */
	private String ip;
	
	/**
	 * API接口名称
	 */
	private String method;

	/**
	 * 时间戳，格式为yyyy-MM-dd HH:mm:ss，例如：2013-05-06 13:52:03。API服务端允许客户端请求时间误差为6分钟。
	 */
	private String timestamp;
	/**
	 * 可选，指定响应格式。默认json,目前支持格式json
	 */
	private String format = "json";

	/**
	 * JOP分配给应用的AppKey ，创建应用时可获得
	 */
	private String appkey;

	/**
	 * API协议版本，可选值:1.0。
	 */
	private String v;

	/**
	 * 流水号
	 */
	private String serialno;

	/**
	 * 等级
	 */
	private String level;

	/**
	 * 参数
	 */
	private String sign;
	
	/**
	 * 状态
	 */
	private String status;
	
	/**
	 * 备注
	 */
	private String memo;

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@NotBlank()
	@Size(max = 100)
	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	@Size(min = 14, max = 14)
	@DateTimeFormat(pattern = "yyyyMMddHHmmss")
	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	@Size(max = 30)
	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	@Size(max = 30)
	public String getAppkey() {
		return appkey;
	}

	public void setAppkey(String appkey) {
		this.appkey = appkey;
	}

	@NotBlank
	@Size(max = 30)
	@Pattern(message = "版本不支持", regexp = "^1.[0|2|3]$")
	public String getV() {
		return v;
	}

	public void setV(String v) {
		this.v = v;
	}
	
	@NotBlank
	public String getSerialno() {
		return serialno;
	}

	public void setSerialno(String serialno) {
		this.serialno = serialno;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
}